#ifndef __TCPCLIENT_H__
#define __TCPCLIENT_H__

#include "Socket.h"
#include "SocketIO.h"
#include "TLV.h"
#include <string>

using std::string;

namespace myNameSpace {
class TcpClient {
public:
    TcpClient();
    void connect(unsigned short port, const string &ip = "127.0.0.1");
    int signup();
    int login();

private:
    int readStdin(char *buf, int len);
    string sendUserName(TaskType type);
    string getSignupSetting();
    string getLoginSetting();
    void sendEncryptedPassword(TaskType type, const string &userName, const string &setting);

    int readPacket(Packet &packet);
    void sendTLV(TaskType type, const char *msg, int len);

private:
    Socket _clientSock;
    SocketIO _sockIO;
    bool _isLooping;
};
} // end of namespace myNameSpace

#endif
